]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
shell-util: Fix capturing scaled views
authorJonas Ådahl <jadahl@gmail.com>
Wed, 7 Jun 2017 06:53:25 +0000 (14:53 +0800)
committerJonas Ådahl <jadahl@gmail.com>
Fri, 14 Jul 2017 13:01:48 +0000 (21:01 +0800)
libmutter-clutter fixed stage capturing when views are scaled, and for
that to work properly when compositing the screenshot, we need to deal
with the cairo device scale here too.

https://bugzilla.gnome.org/show_bug.cgi?id=765011

src/shell-util.c

index f72645c277099c9fb04a6d99cda450b84a779f90..02db9b1060f33cb1a6175f511d81e03cd0e326e8 100644 (file)
@@ -456,27 +456,32 @@ shell_util_composite_capture_images (ClutterCapture  *captures,
                                      int              height)
 {
   int i;
+  double target_scale;
   cairo_format_t format;
   cairo_surface_t *image;
   cairo_t *cr;
 
+  target_scale = 0.0;
+  for (i = 0; i < n_captures; i++)
+    {
+      ClutterCapture *capture = &captures[i];
+      double capture_scale = 1.0;
+
+      cairo_surface_get_device_scale (capture->image, &capture_scale, NULL);
+      target_scale = MAX (target_scale, capture_scale);
+    }
+
   format = cairo_image_surface_get_format (captures[0].image);
-  image = cairo_image_surface_create (format, width, height);
+  image = cairo_image_surface_create (format,
+                                      width * target_scale,
+                                      height * target_scale);
+  cairo_surface_set_device_scale (image, target_scale, target_scale);
 
   cr = cairo_create (image);
 
   for (i = 0; i < n_captures; i++)
     {
       ClutterCapture *capture = &captures[i];
-      double capture_scale = 1.0;
-
-      /*
-       * Ignore capture regions with scale other than 1 for now; mutter can't
-       * produce them yet, so there is no way to test them.
-       */
-      cairo_surface_get_device_scale (capture->image, &capture_scale, NULL);
-      if ((int) capture_scale != 1)
-        continue;
 
       cairo_save (cr);